package oop.core.entity;

import java.util.*;

import oop.core.item.EquippableItem;
import oop.core.skill.ActiveSkill;
import oop.core.skill.InteractiveSkill;
import oop.core.skill.PassiveSkill;

/**
 * Holds Skills and levelUpStats 
 */
public class Occupation {
	private String name;
	private List<InteractiveSkill> interactiveSkill;
	private List<PassiveSkill> passiveSkill;
	private List<ActiveSkill> activeSkill;
	private Stats LevelUpStats;
	
	public Occupation(String name, List<InteractiveSkill> interactiveSkill, List<PassiveSkill> passiveSkill, List<ActiveSkill> activeSkill, Stats stats){
		this.name = name;
		this.interactiveSkill = interactiveSkill;
		this.passiveSkill = passiveSkill;
		this.activeSkill = activeSkill;
		this.LevelUpStats = stats;
	}
	
	public ActiveSkill getDerivedActiveSkill(int position, EquippableItem e){
		ActiveSkill as = activeSkill.get(position).clone();
		boolean wasEffective = as.deriveSkill(passiveSkill, e);
		if(!wasEffective)
			as = null;
		return as;
	}
	
	public InteractiveSkill getInteractiveSkill(int position){
		return interactiveSkill.get(position);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public List<InteractiveSkill> getInteractiveSkill() {
		return interactiveSkill;
	}

	public void setInteractiveSkill(List<InteractiveSkill> interactiveSkill) {
		this.interactiveSkill = interactiveSkill;
	}

	public List<PassiveSkill> getPassiveSkill() {
		return passiveSkill;
	}

	public void setPassiveSkill(List<PassiveSkill> passiveSkill) {
		this.passiveSkill = passiveSkill;
	}

	public List<ActiveSkill> getActiveSkill() {
		return activeSkill;
	}

	public void setActiveSkill(List<ActiveSkill> activeSkill) {
		this.activeSkill = activeSkill;
	}

	public Stats getLevelUpStats() {
		return LevelUpStats;
	}

	public void setLevelUpStats(Stats levelUpStats) {
		LevelUpStats = levelUpStats;
	}
	
	public void doLevelUp(Stats levelStats)
	{
		
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((LevelUpStats == null) ? 0 : LevelUpStats.hashCode());
		result = prime * result
				+ ((activeSkill == null) ? 0 : activeSkill.hashCode());
		result = prime
				* result
				+ ((interactiveSkill == null) ? 0 : interactiveSkill.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((passiveSkill == null) ? 0 : passiveSkill.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Occupation other = (Occupation) obj;
		if (LevelUpStats == null) {
			if (other.LevelUpStats != null)
				return false;
		} else if (!LevelUpStats.equals(other.LevelUpStats))
			return false;
		if (activeSkill == null) {
			if (other.activeSkill != null)
				return false;
		} else if (!activeSkill.equals(other.activeSkill))
			return false;
		if (interactiveSkill == null) {
			if (other.interactiveSkill != null)
				return false;
		} else if (!interactiveSkill.equals(other.interactiveSkill))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (passiveSkill == null) {
			if (other.passiveSkill != null)
				return false;
		} else if (!passiveSkill.equals(other.passiveSkill))
			return false;
		return true;
	}
	
}
